package com.example.department.controller;

import com.example.department.pojo.Dept;
import com.example.department.pojo.Result;
import com.example.department.service.DeptService;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController

public class DeptController {
    @Autowired
private DeptService deptService;

//------------------------------------------------

    @GetMapping("depts")
    public Result list()
 {
     log.info("查询部门数据");

     List<Dept> deptlist = deptService.list();

     return Result.success(deptlist);
 }

//-----------------------------------------
    @DeleteMapping("depts/{id}")
    public Result delete(@PathVariable  Integer id)
    {
        System.out.println("好");
        deptService.delete(id);
        return Result.success();
    }


}
